import styles from './index.less';
import { Button, Table } from 'antd';
import { request, connect } from 'umi';
import { GET_USER_LIST } from '@/actions/user';

const columns = [
  {
    title: '城市',
    dataIndex: 'name',
    key: 'name',
  },
  {
    title: '类型',
    dataIndex: 'type',
    key: 'type',
  },
  {
    title: '值',
    dataIndex: 'value',
    key: 'value',
  },
];

const DashboardPage = ({ user, dispatch }) => {
  console.log(user);

  const { list = [] } = user;

  const getUserList = () => {
    const id = '123';
    dispatch(GET_USER_LIST(id));
  };

  return (
    <div>
      <h1 className={styles.title}>Page index</h1>
      <Button type="primary" onClick={getUserList}>
        点击获取MOCK数据
      </Button>
      <Table dataSource={list} columns={columns} />
    </div>
  );
};

export default connect(({ user }) => ({ user }))(DashboardPage);
